#include "SQLExistsExpr.h"
#include "../../visitor/SQLASTVisitor.h"

SQLExistsExpr::SQLExistsExpr() : xnot(BOOL::FALSE)
{
}

SQLExistsExpr::~SQLExistsExpr()
{
  // if (subQuery != nullptr)
  // {
  //   // delete subQuery;
  //   subQuery = nullptr;
  // }
}
SQLExistsExpr::SQLExistsExpr(SQLSelect_ptr theSubQuery) : subQuery(theSubQuery), xnot(BOOL::FALSE)
{
  // this.setSubQuery(subQuery);
}

SQLExistsExpr::SQLExistsExpr(SQLSelect_ptr theSubQuery, BOOL_ptr theNot) : subQuery(theSubQuery), xnot(theNot)
{
  // this.setSubQuery(subQuery);
  // this.xnot = xnot;
}

BOOL_ptr SQLExistsExpr::isNot()
{
  return xnot;
}

void SQLExistsExpr::setNot(BOOL_ptr theNot)
{
  xnot = theNot;
}

SQLSelect_ptr SQLExistsExpr::getSubQuery()
{
  return subQuery;
}

void SQLExistsExpr::setSubQuery(SQLSelect_ptr theSubQuery)
{
  if (theSubQuery != NULL)
  {
    theSubQuery->setParent(SharedObject(SQLExistsExpr));
  }
  subQuery = theSubQuery;
}

void SQLExistsExpr::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLExistsExpr)))
  {
    acceptChild(visitor, subQuery);
  }

  visitor->endVisit(SharedObject(SQLExistsExpr));
}

// int SQLExistsExpr::hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (xnot ? 1231 : 1237);
// result = prime * result + ((subQuery == null) ? 0 : subQuery.hashCode());
// return result;
//}

// BOOL_ptr SQLExistsExpr::equals(Object obj) {
// if (this == obj) {
// return BOOL::TRUE;
//}
// if (obj == null) {
// return BOOL::FALSE;
//}
// if (getClass() != obj.getClass()) {
// return BOOL::FALSE;
//}
// SQLExistsExpr other = (SQLExistsExpr) obj;
// if (xnot != other.xnot) {
// return BOOL::FALSE;
//}
// if (subQuery == null) {
// if (other.subQuery != null) {
// return BOOL::FALSE;
//}
//} else if (!subQuery.equals(other.subQuery)) {
// return BOOL::FALSE;
//}
// return BOOL::TRUE;
//}
